<template>
	<view>
		<view class="css-nav">
			<view class="css-nav-back" @click="handleBack">
				<image src="../../static/backimg.png" mode="aspectFit" style="width: 100%;height: 100%;"></image>
			</view>
			<view class="css-nav-title">
				我的二维码
			</view>
		</view>

		<view class="css-use">
			<view class="css-usecode">
				邀请码
				<br />
				<span>{{ inviteCode }}</span>
				<image :src="qrcode" mode="aspectFit" style="width: 70vw;height: 70vw;"></image>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				qrcode: "",
				inviteCode: ""
			}
		},

		onShow() {
			var token = uni.getStorageSync('token');
			if (token) {
				this.inviteCode = uni.getStorageSync('inviteCode');

				const baseURL = getApp().globalData.baseURL; //  pro_gdapp_h5

				var header = {};
				header["Authorization"] = token;

				uni.request({
					url: baseURL + "/liantong/getQrUrl",
					header: header,
					success: (res) => {
						console.log(res.data);
						if (res.data.code == 200 || res.data.code == 0) {
							this.qrcode = res.data.data;
						}
					}
				});
			} else {
				uni.reLaunch({
					url: "/pages/login/login"
				});
			}
		},
		methods: {
			handleBack() {
				uni.navigateBack()
			}
		}
	}
</script>

<style scoped lang="scss">
	.css-nav {
		width: 100%;
		height: 64px;
		background-color: #D72743;
		padding: 0 20px;
		display: flex;
		justify-content: flex-start;

		.css-nav-back {
			height: 64px;
			width: 34px;
			padding: 20px 0;
		}

		.css-nav-title {
			height: 64px;
			line-height: 64px;
			text-align: center;
			width: calc(100% - 74px);
			color: #fff;
			font-size: 18px;
			font-weight: 500;
		}
	}

	.css-use {
		background-color: #D72743;
		width: 90vw;
		margin-left: 5vw;
		padding: 30px 10px;
		margin-top: 5vw;
		border-radius: 8px;

		.css-use-name {
			text-align: center;
			color: #fff;
		}

		.css-use-phone {
			text-align: center;
			color: #ddd;
			padding: 10px 0;
		}

		.css-usecode {
			text-align: center;
			color: #fff;
			padding-bottom: 10px;
		}

		.css-usecode span {
			font-size: 24px;
			font-weight: bold;
			line-height: 30px;
		}

		.css-qrcode {
			width: 50vw;
			height: 50vw;
			margin: auto;
		}
	}
</style>